package com.ruoyi.eqmonitor.phase1.service.impl;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.eqmonitor.dtos.OptDeviceDto;
import com.ruoyi.eqmonitor.phase1.domain.OptDevicePhase1;
import com.ruoyi.eqmonitor.phase1.mapper.OptDevicePhase1Mapper;
import com.ruoyi.eqmonitor.phase1.service.IOptDevicePhase1Service;

/**
 * 一期设备管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-03-17
 */
@Service
public class OptDevicePhase1ServiceImpl extends ServiceImpl<OptDevicePhase1Mapper,OptDevicePhase1> implements IOptDevicePhase1Service {
    
    @Autowired
    private OptDevicePhase1Mapper optDevicePhase1Mapper;

    @Override
    public OptDevicePhase1 selectOptDevicePhase1ById(Long id){
        return optDevicePhase1Mapper.selectOptDevicePhase1ById(id);
    }
    
    @Override
    public OptDevicePhase1 selectOptDevicePhase1ByDeviceCode(String code){
        return optDevicePhase1Mapper.selectOptDevicePhase1ByDeviceCode(code);
    }

    @Override
    public List<OptDevicePhase1> listAndMonitorData(OptDevicePhase1 optDevicePhase1) {
        List<OptDevicePhase1> list = optDevicePhase1Mapper.listAndMonitorData(optDevicePhase1);
        for (OptDevicePhase1 phase1 : list){
            String remark = phase1.getRemark();
            //井深 1.2 量程0 79 雨水
            int begin = remark.indexOf("深");
            int end = remark.indexOf("量");
            String result = remark.substring(begin+1, end).trim();
            phase1.setJs(result);
        }
        return list;
    }

    @Override
    public List<OptDevicePhase1> selectOptDevicePhase1List(OptDevicePhase1 optDevicePhase1){
        return optDevicePhase1Mapper.selectOptDevicePhase1List(optDevicePhase1);
    }

	@Override
	public List<OptDeviceDto> selectOptDeviceListAndLastTime(OptDeviceDto optDevice) {
		return optDevicePhase1Mapper.selectOptDeviceListAndLastTime(optDevice);
	}
}
